/*
 * Copyright (c) 2012-2015 The original author or authors
 * ------------------------------------------------------
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * and Apache License v2.0 which accompanies this distribution.
 *
 * The Eclipse Public License is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * The Apache License v2.0 is available at
 * http://www.opensource.org/licenses/apache2.0.php
 *
 * You may elect to redistribute this code under either of these licenses.
 */
package com.chinamobile.iot.mqtt.spi.security;


/**
 * username and password checker
 *
 * @author andrea
 */
public interface IAuthenticator {


    /**
     * when the mqtt client first connect to the server, the protocolProcessor will call this method to check the login
     *
     * @param clientId the clientId in the Connect Message
     * @param username the userName in the Connect Message
     * @param password the password in the Connect Message
     * @return if loginCheck passed, then return the clientInfo, otherwise return null
     */
    MqttClientInfo loginCheck(String clientId, String username, String password);


    /**
     * when the loginCheck successed, the protocolProcessor will call this method to get the rspTopic
     *
     * @param clientInfo the info returned from the function loginCheck
     * @param clientId   the clientId of the mqtt client
     * @return the topic of rsp, the server will publish message on the topic to the client
     */
    String getRspTopic(MqttClientInfo clientInfo, String clientId);

    /**
     * when the client disconnected, the ProtocolProcesser will call this function
     *
     * @param clientId the clientId of the mqtt client
     * @param mqttId   the mqttId of the client
     */
    void onClientDisconnected(String clientId, String mqttId);


}

